//
//  MBOrderPayFooterView.m
//  MemberBusiness-ios
//
//  Created by 掌心 on 2018/6/1.
//  Copyright © 2018年 zhangXin. All rights reserved.
//

#import "MBOrderPayFooterView.h"
#import "MBOrderFooterSectionView.h"

@implementation MBOrderPayFooterView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = COLOR_BG;
        UIView* orderDetailView = [[UIView alloc]init];
        orderDetailView.backgroundColor = [UIColor whiteColor];
        [self addSubview:orderDetailView];
        
        [orderDetailView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self).offset([UIView lf_sizeFromIphone6:10]);
            make.left.equalTo(self);
            make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH, [UIView lf_sizeFromIphone6:140]));
        }];
        
        UILabel* centerTitleLabel = [[UILabel alloc]init];
        centerTitleLabel.text = @"订单信息";
        centerTitleLabel.font = [UIFont lf_systemFontOfSize:15];
        centerTitleLabel.textColor = [UIColor colorWithR:24 G:24 B:24];
        [orderDetailView addSubview:centerTitleLabel];
        
        [centerTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(orderDetailView).offset([UIView lf_sizeFromIphone6:13]);
            make.left.equalTo(orderDetailView).offset([UIView lf_sizeFromIphone6:12]);
        }];
        
        UILabel* typeLabel = [[UILabel alloc]init];
        typeLabel.text = @"已付款";
        typeLabel.font = [UIFont lf_systemFontOfSize:12];
        typeLabel.textColor = [UIColor colorWithR:255 G:0 B:0];
        [orderDetailView addSubview:typeLabel];
        
        [typeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(centerTitleLabel);
            make.right.equalTo(orderDetailView).offset([UIView lf_sizeFromIphone6:-12]);
        }];
        
        MBOrderFooterSectionView* footerC1 = [[MBOrderFooterSectionView alloc]init];
        footerC1.titleLabel.text = @"订单号：";
        footerC1.titleLabel.textColor = [UIColor colorWithR:102 G:102 B:102];
        footerC1.subLabel.text = @"189201805251163";
        footerC1.subLabel.textColor = [UIColor colorWithR:102 G:102 B:102];
        [orderDetailView addSubview:footerC1];
        
        [footerC1 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(centerTitleLabel.mas_bottom).offset([UIView lf_sizeFromIphone6:13]);
            make.left.equalTo(orderDetailView);
            make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH, [UIView lf_sizeFromIphone6:12]));
        }];
        
        MBOrderFooterSectionView* footerC2 = [[MBOrderFooterSectionView alloc]init];
        footerC2.titleLabel.text = @"购买手机号：";
        footerC2.titleLabel.textColor = [UIColor colorWithR:102 G:102 B:102];
        footerC2.subLabel.text = @"15195865875";
        footerC2.subLabel.textColor = [UIColor colorWithR:102 G:102 B:102];
        [orderDetailView addSubview:footerC2];
        
        [footerC2 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(footerC1.mas_bottom).offset([UIView lf_sizeFromIphone6:8]);
            make.left.equalTo(orderDetailView);
            make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH, [UIView lf_sizeFromIphone6:28]));
        }];
        
        MBOrderFooterSectionView* footerC3 = [[MBOrderFooterSectionView alloc]init];
        footerC3.titleLabel.text = @"下单时间：";
        footerC3.titleLabel.textColor = [UIColor colorWithR:102 G:102 B:102];
        footerC3.subLabel.text = @"2018-05-25 10:26:10";
        footerC3.subLabel.textColor = [UIColor colorWithR:102 G:102 B:102];
        [orderDetailView addSubview:footerC3];
        
        [footerC3 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(footerC2.mas_bottom).offset([UIView lf_sizeFromIphone6:8]);
            make.left.equalTo(orderDetailView);
            make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH, [UIView lf_sizeFromIphone6:12]));
        }];
        
        MBOrderFooterSectionView* footerC4 = [[MBOrderFooterSectionView alloc]init];
        footerC4.titleLabel.text = @"数量：";
        footerC4.titleLabel.textColor = [UIColor colorWithR:102 G:102 B:102];
        footerC4.subLabel.text = @"1";
        footerC4.subLabel.textColor = [UIColor colorWithR:102 G:102 B:102];
        [orderDetailView addSubview:footerC4];
        
        [footerC4 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(footerC3.mas_bottom).offset([UIView lf_sizeFromIphone6:8]);
            make.left.equalTo(orderDetailView);
            make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH, [UIView lf_sizeFromIphone6:12]));
        }];
        
        UIView* allMoneyView = [[UIView alloc]init];
        allMoneyView.backgroundColor = [UIColor whiteColor];
        [self addSubview:allMoneyView];
        
        [allMoneyView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(orderDetailView.mas_bottom).offset([UIView lf_sizeFromIphone6:10]);
            make.left.equalTo(self);
            make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH, [UIView lf_sizeFromIphone6:50]));
        }];
        
        UILabel* allMoneyTitleLabel = [[UILabel alloc]init];
        allMoneyTitleLabel.text = @"订单总价";
        allMoneyTitleLabel.font = [UIFont lf_systemFontOfSize:15];
        allMoneyTitleLabel.textColor = [UIColor colorWithR:24 G:24 B:24];
        [allMoneyView addSubview:allMoneyTitleLabel];
        
        [allMoneyTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(allMoneyView);
            make.left.equalTo(allMoneyView).offset([UIView lf_sizeFromIphone6:12]);
        }];
        
        UILabel* moneyLabel = [[UILabel alloc]init];
        moneyLabel.text = @"¥2409.00";
        moneyLabel.font = [UIFont lf_systemFontOfSize:15];
        moneyLabel.textColor = [UIColor colorWithR:255 G:0 B:0];
        [allMoneyView addSubview:moneyLabel];
        
        [moneyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(allMoneyView);
            make.right.equalTo(allMoneyView).offset([UIView lf_sizeFromIphone6:-12]);
        }];
        
        UIButton* cancelButton = [[UIButton alloc]init];
        [cancelButton setBackgroundImage:[UIImage imageFromColor:[UIColor colorWithR:220 G:220 B:220] forSize:CGSizeMake([UIView lf_sizeFromIphone6:100], [UIView lf_sizeFromIphone6:30]) withCornerRadius:[UIView lf_sizeFromIphone6:4]] forState:UIControlStateNormal];
        [cancelButton setTitle:@"取消" forState:UIControlStateNormal];
        cancelButton.titleLabel.font = [UIFont lf_systemFontOfSize:14];
        [cancelButton setTitleColor:[UIColor colorWithR:120 G:120 B:120] forState:UIControlStateNormal];
        [self addSubview:cancelButton];
        
        [cancelButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(allMoneyView.mas_bottom).offset([UIView lf_sizeFromIphone6:40]);
            make.right.equalTo(self.mas_centerX).offset([UIView lf_sizeFromIphone6:-12.5]);
            make.size.mas_equalTo(CGSizeMake([UIView lf_sizeFromIphone6:100], [UIView lf_sizeFromIphone6:30]));
        }];
        
        UIButton* shureButton = [[UIButton alloc]init];
        CAGradientLayer *gradientLayer0 = [[CAGradientLayer alloc] init];
        gradientLayer0.cornerRadius = 4.166666666666666;
        gradientLayer0.frame = CGRectMake(0, 0, [UIView lf_sizeFromIphone6:100], [UIView lf_sizeFromIphone6:30]);
        gradientLayer0.colors = @[
                                  (id)[UIColor colorWithRed:255.0f/255.0f green:136.0f/255.0f blue:0.0f/255.0f alpha:1.0f].CGColor,
                                  (id)[UIColor colorWithRed:255.0f/255.0f green:99.0f/255.0f blue:0.0f/255.0f alpha:1.0f].CGColor];
        gradientLayer0.locations = @[@0, @1];
        [gradientLayer0 setStartPoint:CGPointMake(0, 0)];
        [gradientLayer0 setEndPoint:CGPointMake(1, 1)];
        [shureButton.layer addSublayer:gradientLayer0];
        [shureButton setTitle:@"确认核销" forState:UIControlStateNormal];
        shureButton.titleLabel.font = [UIFont lf_systemFontOfSize:14];
        [self addSubview:shureButton];
        
        [shureButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(allMoneyView.mas_bottom).offset([UIView lf_sizeFromIphone6:40]);
            make.left.equalTo(self.mas_centerX).offset([UIView lf_sizeFromIphone6:12.5]);
            make.size.mas_equalTo(CGSizeMake([UIView lf_sizeFromIphone6:100], [UIView lf_sizeFromIphone6:30]));
        }];
    }
    return self;
}

@end
